<?php
/* 
 * ebiz front
 * 
 * ProductImagesDao Model
 * 
 * @author allen
 * 
 */
require_once '../app/core/models/BaseDao.php';
require_once '../app/core/db/DBUtil.class.php';

class ProductImagesDao extends BaseDao 
{
	
    private $tableName = "product_images";  
    
    public function __construct($dbUtil){ 
        parent::__construct($dbUtil);
    }
    
    public function getDefaultImageByItemId($productItemId){ 
        $param = array($productItemId);
        $sql = "select * from $this->tableName  where `item_id` = ? and `is_delete` = 0 and `default_item` = 1 and `default_item_image` = 1";
        return $this->dbUtil->SelectData($sql, $param);
    }
    
    public function getDefaultItemImageByItemId($productItemId){   
        $param = array($productItemId);
        $sql = "select * from $this->tableName where item_id = ? and default_item_image = 1 and `is_delete` = 0 ";
        return $this->dbUtil->SelectData($sql, $param);
    }
    
    public function getByItemId($itemId){   
        $param = array($itemId);
        $sql = "select * from $this->tableName where item_id = ? and is_delete = 0 order by sort_order";
        return $this->dbUtil->SelectData($sql, $param);
    }
    
    //move to productItemDao
//    public function getDefaultItemByProductId($pid){
//        $param = array($pid);
//        $sql = "select * from $this->tableName where product_id = ? and default_item = 1 and is_delete = 0";
//        return $this->dbUtil->SelectData($sql, $param);
//    }
    
}



